﻿namespace Lzhdim.WinSrvMgr.Forms
{
    using Lzhdim.Animation.UI;
    using System;
    using System.Drawing;
    using System.IO;
    using System.Reflection;
    using System.Windows.Forms;

    /// <summary>
    /// 关于窗体
    /// </summary>
    internal partial class WndAbout : FormBase
    {
        /// <summary>
        /// 构造函数
        /// </summary>
        internal WndAbout()
        {
            InitializeComponent();

            this.Size = this.MaximumSize = this.MinimumSize = new Size(this.PanelBackground.Width, this.PanelBackground.Height);
        }

        /// <summary>
        /// 窗体关闭后事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void AboutForm_FormClosed(object sender, FormClosedEventArgs e)
        {
            this.DialogResult = DialogResult.OK;
        }

        /// <summary>
        /// 加载完成时事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void AboutForm_Load(object sender, EventArgs e)
        {
            string name = Assembly.GetExecutingAssembly().GetName().Name;
            int index = name.IndexOf('.');

            if (index > 0)
            {
                name = name.Substring(0, index);
            }

            string path = Application.StartupPath + "\\" + name + ".exe";

            if (!File.Exists(path))
            {
                MessageBox.Show("请勿更改此应用程序名称！", name, MessageBoxButtons.OK);

                this.Close();
            }

            System.Diagnostics.FileVersionInfo ver = System.Diagnostics.FileVersionInfo.GetVersionInfo(path);

            this.lblAbout.Text = Properties.Resources.UseAbout + Environment.NewLine + Environment.NewLine
                                + "产品名：" + "\t" + ver.ProductName + Environment.NewLine
                                + "公司名：" + "\t" + ver.CompanyName + Environment.NewLine
                                + "版权：" + "\t\t" + ver.LegalCopyright + Environment.NewLine
                                + "商标：" + "\t\t" + ver.LegalTrademarks + Environment.NewLine
                                + "文件版本：" + "\t" + ver.FileVersion + Environment.NewLine
                                + "文件描述：" + "\t" + ver.Comments;
        }

        /// <summary>
        /// 移动条鼠标按下事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void lblMoveBar_MouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                MouseDownEffect(this);
            }
        }

        /// <summary>
        /// 移动条鼠标弹起事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void lblMoveBar_MouseUp(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Right)
            {
                ShowSystemMenu(e.Button);
            }
        }

        /// <summary>
        /// 关闭窗体菜单事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void TSMClose_MouseUp(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                this.Close();
            }
        }
    }
}